Repository navigation
Conversation
…stop Set connect 30 s, read 60 s and write 60 s on the OkHttp client. Before, only the 24 h call cap was set, so OkHttp's 10 s defaults applied, and a server that took more than 10 s to answer made the phone send again. Extract awaitLanded() from awaitResponse(). It saves a result before the resume, and a stop returns that result when it is there. A plain suspendCancellableCoroutine drops it. A stop with no result still cancels the call and throws. A chunked part saves its accepted flag the same way. Comments and two EntryRunTest cases pin that nothing suspends between the returned response and ops.settle or markAccepted. retryOnConnectionFailure is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Connect timeout 15 s, not 30 s. OkHttp tries the next address of a host only after a connect timeout, so a host with several addresses that do not answer holds a transfer slot for that many timeouts. A connect timeout cannot make a duplicate, because nothing was sent yet. Read and write stay 60 s. The CHANGELOG and the awaitLanded comment now say what the code does: it keeps a response OkHttp finished reading before the stop took effect. Before, the request was sent again at once after a system stop, and at resume() after a pause. A response not yet read when the stop lands is still lost. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ackoff - AwaitResponseTest runs okhttpSend against a local socket server with a manual dispatcher. A landed response survives a stop and the connection is reused. A stop with no response cancels the call. A stop before the call sends nothing. A body that fails to read is not kept as landed. - TransferGateStopTest: the gate returns the block's value on a stopped job, in both lanes. - FakeHost.sleep() now throws on a stopped job, as a real delay does (the same form as on dylan/android-stop-not-failure). New test: a 500 that lands at a stop is counted once and the entry goes back to queued. No new dependency. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
awaitResponseused a plainsuspendCancellableCoroutine. Sometimes OkHttp finished reading the response, and then a stop (a system stop, orpause()) took effect before the coroutine ran again. In that case kotlinx dropped the response. Its docs say the coroutine "will not resume successfully, even if CancellableContinuation.resume was already invoked". The request was then sent again: at once after a system stop, or atresume()after a pause.What changes
UploadTransport.kt: connect 15 s, read 60 s, write 60 s. The 24 h call cap stays, and its comment now says what it covers.URLSessiondefault of 60 s.UploadUtils.kt: newawaitLanded(register, cancel), taken out ofawaitResponse. It saves the result in anAtomicReferencebefore the resume. On a stop it returns the saved result if there is one. A stop with no result cancels the call and throws, as before. A failure that came first is thrown as before.EntryRun.attempt,SimpleTransferandChunkedTransfersay that nothing may suspend between the returned response andops.settleormarkAccepted. Tests pin this.Not changed:
retryOnConnectionFailure(still OkHttp's default, on), iOS, part size, the retry table.Behavior change
cancel()is unchanged: the entry still settlescancelled.What it does not fix
cancel()and a 200 land together, the entry correctly endscancelledwith one outcome. But the run still ends its progress as completed. This is open.Tests
UploadHttpClientTest: the client's connect, read, write and call timeouts.AwaitLandedTestchecks:AwaitResponseTestrunsokhttpSendon real OkHttp, against a small local socket server, with a dispatcher the test drives by hand. No new dependency. It checks:TransferGateStopTest: the transfer gate returns the response on a stopped job, in both lanes.EntryRunTestcovers three cases:sleep()now throws on a stopped job, as a realdelaydoes.Before the fix, the timeout test and the landed-result test failed. To check the tests, each fix was broken on purpose, and at least one test failed each time:
call.cancel()replaced by nothing.ops.settle, inSimpleTransfer, or beforemarkAccepted.sleep()no longer throwing.Checks run locally, all exit 0:
yarn lint:ciyarn typecheckyarn test(305 tests)./gradlew :react-native-background-upload:testDebugUnitTest(439 tests)swift testinios/(383 tests, 1 skipped)An independent review was applied. Part of RAD-17385.
🤖 Generated with Claude Code